package com.yupi.springbootinit.controller;



import com.yupi.springbootinit.common.BaseResponse;
import com.yupi.springbootinit.common.ErrorCode;
import com.yupi.springbootinit.common.ResultUtils;
import com.yupi.springbootinit.exception.ThrowUtils;
import com.yupi.springbootinit.model.dto.UserUpdateRequest;
import com.yupi.springbootinit.model.entity.Dept;
import com.yupi.springbootinit.model.entity.User;
import com.yupi.springbootinit.service.DeptService;
import com.yupi.springbootinit.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.security.PrivilegedAction;

/**
 * 公司表(Dept)表控制层
 *
 * @author makejava
 * @since 2024-03-12 15:15:23
 */
@RestController
@RequestMapping("dept")
public class DeptController  {
    /**
     * 服务对象
     */
    @Resource
    private DeptService deptService;

    @Resource
    private UserService userService;

    @PostMapping("/update")
    public BaseResponse<Dept> updateDept(@RequestBody Dept dept,HttpServletRequest request) {
        User loginUser = userService.getLoginUser(request);
        Integer deptId = loginUser.getDeptId();
        dept.setId(deptId);
        deptService.updateById(dept);
        return ResultUtils.success(dept);
    }
}

